#include "First.h"
#include "Router.h"
#include "PageShower.h"
#include <iostream>

void First::show()
{
	std::cout << "First Page" << std::endl;
	std::cout << "1.one...\n";
	std::cout << "2.tow...\n";
	std::cout << "0.exit\n";
}

void First::choose()
{
	int in{};
	std::cin >> in;
	auto ptr{ dynamic_cast<PageShower*>(parent.get()) };
	switch (in) {
	case 0:
		if (nullptr == ptr) {
			abort();
		}
		ptr->setState(State::Closing);
		break;
	case 1:
		Router::push(parent, "FirstPage/1");
		break;
	case 2:
		Router::push(parent, "FirstPage/2");
		break;
	default:
		break;
	}

}

struct FirstPageRegister{
	FirstPageRegister() {
		Router::Add::addPage("/", [](std::shared_ptr<ChangePage> parent)->std::unique_ptr<Page> {
			return move(std::make_unique<First>(parent));
			});
	}
}_{};